/*LICENSE_BEGIN
 * ******************************************************************
 * All original parts of SoccerScope2003 have copyright (2003) by
 * Team YowAI, represented by Mr. Shuhei Shiota
 * The Department of Creative Informatics
 * The Graduate School of Information Science and Technology
 * The University of Tokyo
 * 
 * Additional classes (except libraries in /lib) were developed by 
 * the Dainamite Robocup-Team of the DAI-Labor, TU-Berlin 
 * (www.dai-labor.de)
 * 
 * Extended/new classes/packages are:
 *   soccerscope.analyzer.LogfileAnalyzer
 *   soccerscope.daistatistic.*
 *   soccerscope.daistatistic.charts.*
 *   soccerscope.daistatistic.tools.*
 *   soccerscope.db.*
 *   soccerscope.dialog.*
 *   soccerscope.model.PlayerWorldModel
 *   soccerscope.model.SimplePlayer
 *   soccerscope.net.AgentConnector
 *   soccerscope.training.*
 *   soccerscope.training.conditions.*
 * ******************************************************************
LICENSE_END*/
package soccerscope.daistatistic.charts;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;

/**
 * 
 * this class provides functions to create specific chart images selects player
 * and chart type and shows that chart in a frame
 * 
 */
public class ChartCreator {

	/**
	 * 
	 * create an XY-jFreeChart note: the values of xValues and yValues must
	 * correspond for a proper graph example: if x is stored in xValues[3] the
	 * f(x) must be stored in yValues[3]
	 * 
	 * @param String
	 *            headline, text shown in top of the image
	 * @param String
	 *            x, x-axis titel
	 * @param String
	 *            y, y-axis titel
	 * @param String
	 *            seriesName, plot titel
	 * @param double[]
	 *            xValues, values for x-axis
	 * @param double[]
	 *            yValues, values for y-axis
	 */
	public static JFreeChart createXYFreeChart(String headline, String x,
			String y, String seriesName, double[] xValues, double[] yValues) {

		XYDatasetImpl data = new XYDatasetImpl(); // create a new XYDataset
		data.setSeriesName(seriesName); // set series name
		data.setXValues(xValues); // set values
		data.setYValues(yValues);

		// create the jFreeChart with given values
		JFreeChart chart = ChartFactory.createXYLineChart(headline, x, y, data,
				PlotOrientation.VERTICAL, true, true, true);
		return chart; // return the chart
	}

	/**
	 * 
	 * create an XY-jFreeChart with two series note: the values of xValues and
	 * yValues must correspond for a proper graph example: if x is stored in
	 * xValues[3] the f(x) must be stored in yValues[3]
	 * 
	 * @param String
	 *            headline, text shown in top of the image
	 * @param String
	 *            x, x-axis titel
	 * @param String
	 *            y, y-axis titel
	 * @param String
	 *            seriesName1, plot titel for function 1/serie 1
	 * @param String
	 *            seriesName2, plot titel for function 2/serie 2
	 * @param double[]
	 *            xValues, values for x-axis
	 * @param double[]
	 *            yValues1, values for y-axis of function 1/serie 1
	 * @param double[]
	 *            yValues2, values for y-axis of functino 2/serie 2
	 */
	public static JFreeChart createXYFreeChartWith2Series(String headline,
			String x, String y, String seriesName1, String seriesName2,
			double[] xValues, double[] y1Values, double[] y2Values) {

		XYDatasetTwoSeriesImpl data = new XYDatasetTwoSeriesImpl(); // create a
		// new
		// XYDataset
		data.setSeriesName(seriesName1, 0); // set series names
		data.setSeriesName(seriesName2, 1);
		data.setXValues(xValues); // set values
		data.setYValues(y1Values, 0);
		data.setYValues(y2Values, 1);

		// create the jFreeChart with given values
		JFreeChart chart = ChartFactory.createXYLineChart(headline, x, y, data,
				PlotOrientation.VERTICAL, true, true, true);
		return chart; // return the chart
	}

	/**
	 * 
	 * create an XY-jFreeChart with 11 series note: the values of xValues and
	 * yValues must correspond for a proper graph example: if x is stored in
	 * xValues[3] the f(x) must be stored in yValues[3]
	 * 
	 * @param String
	 *            headline, text shown in top of the image
	 * @param String
	 *            x, x-axis titel
	 * @param String
	 *            y, y-axis titel
	 * @param XYDataset11SeriesImpl
	 *            data, the dataset for the jfreechart
	 */
	public static JFreeChart createXYFreeChartWith11Series(String headline,
			String x, String y, XYDataset11SeriesImpl data) {
		// create the jFreeChart with given values
		JFreeChart chart = ChartFactory.createXYLineChart(headline, x, y, data,
				PlotOrientation.VERTICAL, true, true, true);
		return chart; // return the chart
	}

}

